package com.hx.springboot1.controller;

import com.github.pagehelper.PageInfo;
import com.hx.springboot1.dao.ScoreDao;
import com.hx.springboot1.pojo.entity.TabCourse;
import com.hx.springboot1.pojo.entity.TabScore;
import com.hx.springboot1.service.impl.CourseServiceImpl;
import com.hx.springboot1.service.impl.ScoreServiceImpl;
import com.hx.springboot1.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Author: hx
 * Date: 2021-05-24 14/45
 * Description: Nothing else
 */
@Controller
public class ScoreController {
    @Autowired
    ScoreServiceImpl scoreService;
    @RequestMapping("/selectScore")
    public String selectScore(String searchName, String pageNum, String pageSize, Model model){
        PageInfo pageInfo = scoreService.selectAllScore(searchName, pageNum, pageSize);
        model.addAttribute("pageInfo",pageInfo);
        return "manage/scoreList";
    }
    @PostMapping("/insertOrUpdateScore")
    @ResponseBody
    public ResultMsg iouScore(Integer scoreId,Integer stuId,String stuName,Integer courseId,Integer scoreTime,Integer scoreScore){
        return scoreService.insertOrUpdateScore(scoreId,stuId,stuName,courseId,scoreTime,scoreScore);
    }
    @GetMapping("/selectScoreByScoreId")
    @ResponseBody
    public TabScore sSbI(Integer scoreId){
        return scoreService.selectScoreByScoreId(scoreId);
    }
    @GetMapping("/deleteScoreInfo")
    @ResponseBody
    public ResultMsg deleteScore(Integer SID){
        return scoreService.delScore(SID);
    }
    @RequestMapping("/getScoreReport")
    public String getSR(Integer yearId,Integer pageNum,Integer pageSize,Model model){
        PageInfo pageInfo = scoreService.selectScoreReport(yearId, pageNum, pageSize);
        model.addAttribute("pageInfo",pageInfo);
        return "reportForms/scoreReport";
    }
}
